pp108 : Using WS-AppServer Custom Class as an Alternative to Object Template

Using WS-AppServer Custom Class as an Alternative to Object Template

This topic describes the procedure to use WS-AppServer custom class as an alternative to Object Template.

Object Template has been deprecated in BOP 4.1. Hence, you cannot create a new Object Template from document creation wizard. However, if there are object templates used in the applications build prior to BOP 4.1, you can create and use WS-AppServer Custom Classes replicating the object template schema.
Similar to an Object Template, you can do the following with WS-AppServer custom class:

  • Generate schema and schema fragments
  • Provide unique fields (analogous to the Special Attribute feature of Object Template)
  • Generate Web services, use these Web services to fetch the instances matching the search criteria.
  • Model rule(s), decision table(s), and data transformation(s)

This page illustrates the procedure and guidelines that are used to create a custom class and remodel the object template schema to WS-AppServer custom class.

Let us consider the following example that requires data transformation from SapOrder to BaanOrder schema. The objective of the Transformation application is to map common elements of these two structures.

SapOrder instance
<sap:SapOrder xmlns:sap="http://schemas.cordys.com/SapApp">
    <sap:OrderId/>
    <sap:OrderDate/>
    <sap:OrderedBy/>
    <sap:CustomerId/>
    <sap:CustomerAddress/>
    <sap:ShipmentDate/>
</sap:SapOrder>
BaanOrder instance
<baan:BaanOrder xmlns:baan="http://schemas.cordys.com/BaanApp">
    <baan:OrderIdentifier/>
    <baan:CustomerIdentifier/>
    <baan:OrderDate/>
    <baan:ShipmentDate/>
    <baan:OrderDetails/>
    <baan:ShipmentAddress/>
</baan:BaanOrder>

Data transformation can be created using the schema fragments that are generated by either of the following documents:

  • Object Templates
  • WS-AppServer Custom Class

However, in BOP 4.1, since you cannot create a new Object Template, you can use a WS-AppServer Custom Class to achieve the result. This section contains the procedure on using the WS-AppServer custom class instead of an Object Template.

Using WS-AppServer Custom Class in the Transformation application

Pre-requisites

It is assumed that:

  • user has "Developer" and "Administrator" role
  • user has already created a workspace and a project or has an existing CWS project.
  1. Create a new WS-AppServer Package, for instance, SapApp which has the namespace='http://schemas.cordys.com/SapApp'.
    Note: Ensure that the namespace of this package is same as the namespace of the object template
  2. On the WS-AppServer Package toolbar, click . The Create Class from Object Layout dialog box appears.
  3. Use the following object layout for the SapOrder schema.

    Note: You can use the Layout Tree tab to build the layout. If you are familiar with the WS-AppServer custom class layouts, you can directly use the layout. In this instance, all the elements are of type 'string'. If required, you can use a relevant type.

    SapOrder Pure Custom Class Layout
    <SapOrder>
        <OrderId unique="true">string</OrderId>
        <OrderDate>string</OrderDate>
        <OrderedBy>string</OrderedBy>
        <CustomerId>string</CustomerId>
        <CustomerAddress>string</CustomerAddress>
        <ShipmentDate>string</ShipmentDate>
    </SapOrder>
    
  4. Click OK. A custom class with the relevant attributes and methods is generated.
  5. On the WS-AppServer Package toolbar, click on Generate WebServiceInterface. A Web service generation wizard is displayed.
  6. Select the custom class and follow instructions on the wizard. At the end, a Web service Interface along with the Schema for SapOrder is generated.
  7. Repeat the steps 1 to 5 for creating BaanOrder. Provide the following details in the relevant fields:
    1. WS-AppServer package name = BaanApp
    2. WS-AppServer package namespace='http://schemas.cordys.com/BaanApp'
    3. Custom class object layout
      BaanOrder Pure Custom Class Layout
      <BaanOrder>
          <OrderIdentifier unique="true">string</OrderIdentifier>
          <CustomerIdentifier>string</CustomerIdentifier>
          <OrderDate>string</OrderDate>
          <ShipmentDate>string</ShipmentDate>
          <OrderDetails>string</OrderDetails>
          <ShipmentAddress>string</ShipmentAddress>
      </BaanOrder>
      
  8. The schema for SapOrder and BaanOrder custom classes is generated along with the corresponding schema fragments.
  9. Create a new Data Transformation model , for instance, Sap_To_Baan_Transformation.
  10. Select SapOrder schema fragment as the Source and BaanOrder schema fragment as the target in the transformation modeler.
  11. Define the mappings.
  12. Generate a Web service on Sap_To_Baan_Transformation with SapOrder schema fragment as the input and use it in your application. For more information on generating a Web service on data transformation models, refer to Generating a Web service on Data Transformation Model

Guidelines to remodel Object Templates in the existing applications to WS-AppServer Custom Class

In order to have no break in the applications that used object templates, it is recommended to remodel the object templates to WS-AppServer Custom Classes. This section provides the guidelines to be followed while remodeling the object template into a WS-AppServer Custom Class.

  1. Create a WS-AppServer Custom Class that is same as the structure of the Object Template.
    1. If an Object Template had any special attributes, ensure that those attributes are qualified as unique attributes while modeling a custom class from object layout.
  2. If an Object Template is marked as 'Persistent', based on the object template structure, you can do any of the following:
    1. If Object Template is a simple structure, that is, a structure that does not have any nested elements , you can create the database table representing this structure (ORM) and generate WS-AppServer class(es) from the database. In this case, you need not write any additional logic in the generated class to persist the instance in application database; it is taken care by WS-AppServer framework itself.
    2. Use a 'Pure Custom' class. You can use this regardless of simple or nested structure. However, if you use this option, you must write additional business logic to persist the instance data in the application database.
  3. If the application is using Web services generated on object template, while generating Web services for custom class, you must ensure that name of the Web service and the names of the parameters match; that is, the custom class method and parameter names must match the parameter names of Web service generated on an object template.
  4. Since the Web service(s) generated on custom class are interpreted by the WS-AppServer framework, you have to delink the namespace from CoBOC Service Group and attach the Web services generated on custom class to WS-AppServer Service Group.
  5. If an object template had rules, decision table, or data transformations associated to it, then you have to update or remodel the respective rules, decision table or data transformation instances to use the schema fragments generated for WS-AppServer custom class and re-publish it.